﻿<UserControl x:Class="TimePunch.Metro.Wpf.Controls.Picker.TimePicker"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Converter="clr-namespace:TimePunch.Metro.Wpf.Converter" mc:Ignorable="d" 
             d:DesignHeight="100" d:DesignWidth="300">

    <UserControl.Resources>
        <Converter:ShortTimeConverter x:Key="ShortTimeConverter" />
        <Converter:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </UserControl.Resources>

    <Grid x:Name="TimePickerContent"
            HorizontalAlignment="Stretch"
            IsHitTestVisible="True"
            MouseLeftButtonDown="OnEnterFullModeViaClick"
            TouchUp="OnEnterFullModeViaTouch"
            Cursor="{Binding PickerCursor}"
            Background="{StaticResource WinChromeBrush}">
        
        <TextBlock 
            Visibility="{Binding IsTouchSelectionEnabled, Converter={StaticResource BooleanToVisibilityConverter}}"
            Text="{Binding Value, Converter={StaticResource ShortTimeConverter}}" 
            Style="{StaticResource WinTextNormalStyle}" 
            IsEnabled="{Binding IsEnabled}"
            Margin="{StaticResource WinMargin}"
            Foreground="{StaticResource WinTextBoxForegroundBrush}"/>

        <TextBox
                Visibility="{Binding IsTouchSelectionEnabled, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=true}"
                Text="{Binding TimePickerValue, Converter={StaticResource ShortTimeConverter}, Mode=TwoWay}" 
                Style="{StaticResource WinInputTextNormalStyle}" 
                IsEnabled="{Binding IsEnabled}"
                IsReadOnly="{Binding IsReadonly}"
                Foreground="{StaticResource WinTextBoxForegroundBrush}"
                Background="Transparent"
                BorderThickness="0"
                Margin="{StaticResource WinMargin}"/>
    </Grid>
</UserControl>
